package com.wuyan.locationdog.adapter

import android.graphics.Color
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.FenceSetTypeBean
import com.blankj.utilcode.util.ColorUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R
import leifu.shapelibrary.ShapeView


class FenceSetTypeAdapter(@LayoutRes layoutResId: Int, data: MutableList<FenceSetTypeBean>?) :
    BaseQuickAdapter<FenceSetTypeBean, BaseViewHolder>(layoutResId, data) {

    override fun convert(holder: BaseViewHolder, item: FenceSetTypeBean) {
        holder.setText(R.id.name, item.name)
        val shapeView =  holder.getView<ShapeView>(R.id.shapeView)

        if (item.isSelect) {
            holder.setVisible(R.id.iv_select, true)
            holder.setTextColorRes(R.id.name, com.arcsoft.commonbase.R.color.text_color_selected)

            shapeView.setShapeStrokeColor(ColorUtils.getColor(com.arcsoft.commonbase.R.color.text_color_selected))
                .setShapeSolidColor(Color.WHITE)
                .setUseShape()
        } else {
            holder.setGone(R.id.iv_select, true)
            holder.setTextColorRes(R.id.name, com.arcsoft.commonbase.R.color.color_3)
            shapeView.setShapeStrokeColor(Color.parseColor("#DCDEE0"))
                .setShapeSolidColor(Color.WHITE)
                .setUseShape()
        }
    }

}

